﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Database;
public partial class admin_SuaKH : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        var pm = new checkLogin();
        pm.redirectToLoginPage();
        if (!IsPostBack)
            {
                if (Session["tenkh"] == "Admin")
                {
                    Response.Redirect("Login.aspx");
                }
                else
                {
                    XuLyXuat();
                }
            }


        }
        public void XuLyXuat()
        {
            string tenkh =Request.QueryString["tenkh"].ToString();
            //string tenkh = Request.Params["tenkh"].ToString();
            KhachHang kh = new KhachHang();
            kh = kh.ThongTinKH(tenkh);            
            this.txtTenKH.Text = kh.Tenkh;
            this.txtMatKhau.Text = kh.Matkhau;
            this.txtDiaChi.Text = kh.Diachi;
            this.txtDienThoai.Text = kh.Dienthoai;
            this.txtEmail.Text = kh.Email;

        }

        protected void btCancel_Click(object sender, EventArgs e)
        {
            txtTenKH.Text = "";
            txtMatKhau.Text = "";
            txtDiaChi.Text = "";
            txtDienThoai.Text = "";
            txtEmail.Text = "";
        }

        protected void btSave_Click(object sender, EventArgs e)
        {            
            KhachHang kh = new KhachHang();
            kh.CapNhatKH(this.txtTenKH.Text,this.txtMatKhau.Text, this.txtDiaChi.Text, this.txtDienThoai.Text, this.txtEmail.Text);
            Response.Redirect("HienThiKH.aspx");
            
        }

        protected void txtTenKH_TextChanged(object sender, EventArgs e)
        {
           
        }
    
}
